home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq15.zip
/
MARKMAIL.SLT
< prev
next >
Wrap
Text File
|
1991-02-08
|
12KB
|
357 lines
//-----------------------------------------------------------
// MarkMail.SL? Telix script to fetch mail from a PCBoard BBS.
//
// This script is normally called from the script PCBOARD.SLC.
//
// Please look at the comments through the whole file, and modify to
// suit your needs, BEFORE you use it. Then recompile with CS MarkMail.
//-----------------------------------------------------------
// This script is assumed to be called ONLY after logon
// to perform routine tasks. This is done from the LOGON
// script, and the system can ONLY be PCBOARD. Also,
// we MUST be online in order to arrive here, and the
// TELIX main directory must be the current one.
// Therefore, system and online checks are simply skipped.
str codename [12] // BBS code/filename
,myprot [2] // My protocol
,help [80] // Help line.
,runstr [80] // DSZ runstring (if used).
,downdir [64] // Save of download directory.
// Script and global names:
,global []="GLOBAL" // Global script.
,Cprot []="CPROT" // Current protocol.
,Cname []="CNAME" // Codename of current BBS.
,prompt []="PROMPT" // Current command prompt.
,mdir []="MDIR" // Mail directory.
,dsz []="DSZ" // Code for DSZ (if in use).
;
int tol = 300 // No activity for 30 sec.
,tmark // makes script time out.
,stat // For tracking.
;
//-----------------------------------------------------------
// MarkMail script is entered here.
//-----------------------------------------------------------
main()
{
int c
,i
,l
,na
,save
,MailOK
,error // Error ind.
,com // command
,pnm // Packet name
,stf // Start transfer
,don // [G]oodbye When Done?
;
entry(); // Updates status bar.
newdir (_telix_dir); // Must be in TELIX main directory!
read (cprot,myprot); // Get current BBS protocol.
pnm = 0;
if (read(cname,Codename) < 0) // If codename is unknown,
pnm = track ("ket Name: ",0); // Get packet name.
com = track (" Command?",0); // Command.
stf = track ("s Transfer",0); // Start tracking this now.
tmark = timer_start (tol); // Give me a minute.
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == com)
cputs ("U^M"); // Start upload.
else if (stat == pnm) // Packet name?
{ waitfor ("^J",1); // Wait for linefeed.
for (l=gety()-1; l>=0; --l) // Get previous line.
{ vgetchrs(0,l,help,0,80);
if ((i=strposi (help,"ket Name: ",0)) > 0) // Packet name?
{ i = i+10;
na = 0;
while ((c=subchr(help,i)) != '.') // All before decimal point:
{ setchr(codename,na,c);
if (++na >= 12) break;
}
setchr (codename,na,0); // End the string.
write (cname,codename); // Save BBS ID-code.
break; // Break out of (inner) loop.
}
}
}
else if (stat==stf) // Start transfer
break;
}
release(); // Release tracks.
if (stat < 0) goto done; // Time-out or carrier lost.
// Start sending the mail packet.
help = _up_dir; // Get upload dir.
strcat (help,codename); // Add name.
strcat (help,".REP"); // Add extension.
if (filesize(help) <= 0) // No file to send?
{ release();
MarkAbort(); // Abort transfer.
}
else
{ send_file (); // Send it.
fdelete (help); // Remove the mail file.
}
// Start download.
//-----------------------------------------------------------
save = _zmod_auto;
MailOK = _zmod_auto = 0; // Disable Zmodem-auto.
downdir = _down_dir;
read (mdir,_down_dir); // D/L to this directory.
// Define strings for tracking.
//-----------------------------------------------------------
stf = track ("s Transfer",0); // Start transfer.
com = track (" Command?",0); // Back to command.
pnm = track ("No Message",0); // No messages.
don = track ("When Done?",0); // Wanna receive?
track ("...",0); // Still searching.
track (" ",0); // Still searching.
cputs ("D^M"); // Download now.
tmark = timer_start (tol); // Give me a minute.
error = 1;
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == stf) // Download now?
{ error = get_file();
_down_dir = downdir; // Restore download dir.
}
else if (stat==pnm)
error = 0; // No messages. Simulate "done".
else if (stat==don) // Wanna receive now?
cputs ("y^M");
else if (stat==com)
{ if (MailOK)
break; // MailOK is used to
cputs ("qu^M"); // indicate if we have
MailOK = 1; // returned to PCBoard.
}
}
done:
release(); // Free all tracks and timer.
if (stat < 0) failtone();
_zmod_auto = save;
_down_dir = downdir; // Restore download dir.
return (error);
}
//-----------------------------------------------------------
// Routine to update colors and status bar.
//-----------------------------------------------------------
entry ()
{
_back_color = 1;
_fore_color = 14;
update_term();
}
//-----------------------------------------------------------
// Play fail tone.
//-----------------------------------------------------------
failtone()
{
int n;
for (n=140; n > 10; n = 100*n/120)
{ tone(n*10,12); // Fail tone!!
terminal(); // Process text.
}
}
//-----------------------------------------------------------
// Play good tune.
//-----------------------------------------------------------
goodtone()
{
int n;
for (n=20; n < 200; n = 144*n/100)
{ tone(n*10,6); // Good tone!
terminal(); // Process text.
}
}
//-----------------------------------------------------------
// Free timer and tracking functions.
//-----------------------------------------------------------
release()
{
timer_free (tmark); // free timer channel
track_free (0); // and all track channels.
}
//-----------------------------------------------------------
// Trig loop. Waits here until either one "trig string" is
// found, or we have a time-out, or carrier is lost.
//-----------------------------------------------------------
trig()
{
int i;
do
{ terminal();
} while (!time_up (tmark) // Loop until time-out
&& carrier() // or carrier lost
&& (i=track_hit(0))==0); // or we trigged.
if (i==0)
i = -1; // Error!
else
timer_restart (tmark,tol); // Restore timer.
return (i);
}
//----------------------------------------------------------
// Abort MarkMail door.
//-----------